  const state = {
      // hotSearList组件，向下滑动的高度
      hotSearchOffsetY: 0,
      flapcardVisible: false,
      isEditMode: false, // 点击右上角编辑进入编辑模式(进行选择图书操作)
      shelfList: localStorage.getItem('shelfList') ? JSON.parse(localStorage.getItem('shelfList')) : [], // 书架列表
      shelfSelected: [], // 书架中被选择图书列表
      shelfTitleVisible: true, // 书架标题显示状态
      shelfCategory: [], // category页面数组，书架的分组/分类数据
      currentType: 1 // shelf页面为1，categoty为2
  }
  const mutations = {
      SET_HOT_SEARCH_OFFSETY(state, hotSearchOffsetY) {
          state.hotSearchOffsetY = hotSearchOffsetY
      },
      SET_FLAPCARD_VIVIBLE(state, flapcardVisible) {
          state.flapcardVisible = flapcardVisible
      },
      SET_IS_EDIT_MODE(state, isEditMode) {
          state.isEditMode = isEditMode
      },
      SET_SHELF_LIST(state, list) {
          state.shelfList = list
      },
      SET_SHELF_SELECTED(state, selected) {
          state.shelfSelected = selected
      },
      SET_SHELF_TITLE_VISIBLE(state, visible) {
          state.shelfTitleVisible = visible
      },
      SET_SHELF_CATEGORY(state, category) {
          state.shelfCategory = category
      },
      SET_CURRENT_TYPE(state, type) {
          state.currentType = type
      },
      ADD_SHELF_LIST(state, obj) {
          const data = state.shelfList
          data.push(obj)
          localStorage.setItem('shelfList', JSON.stringify(data))
      }
  }
  const actions = {
      // store部分开始
      setHotSearchOffsetY({
          commit
      }, hotSearchOffsetY) {
          return commit('SET_HOT_SEARCH_OFFSETY', hotSearchOffsetY)
      },
      setFlapcardVisible({
          commit
      }, flapcardVisible) {
          return commit('SET_FLAPCARD_VIVIBLE', flapcardVisible)
      },
      setIsEditMode({
          commit
      }, isEditMode) {
          return commit('SET_IS_EDIT_MODE', isEditMode)
      },
      setShelfList({
          commit
      }, list) {
          return commit('SET_SHELF_LIST', list)
      },
      addShelfList({
          commit
      }, obj) {
          console.log('我运行了');
          console.log(obj);
          commit('ADD_SHELF_LIST', obj)
          return Promise.resolve()
      },
      setShelfSelected({
          commit
      }, selected) {
          return commit('SET_SHELF_SELECTED', selected)
      },
      setShelfTitleVisible({
          commit
      }, visible) {
          return commit('SET_SHELF_TITLE_VISIBLE', visible)
      },
      setShelfCategory({
          commit
      }, category) {
          return commit('SET_SHELF_CATEGORY', category)
      },
      setCurrentType({
          commit
      }, type) {
          return commit('SET_CURRENT_TYPE', type)
      }
  }
  export default {
      namespaced: true,
      mutations,
      actions,
      state,
  }